<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>
    function fn(str) {
        var arr = []
        if (str.length <= 1) {
            return [str]
        }
        else {
            for (var i = 0; i < str.length; i++) {
                var first = str[i]
                var vsfirst = str.slice(0, i) + str.slice(i + 1, str.length)
                var arrs = fn(vsfirst)
                for (var j = 0; j < arrs.length; j++) {
                    var temp = first + arrs[j]
                    arr.push(temp)
                }
            }
        }
        return arr
    }
    var str = fn('abc')
    console.log(str);
</script>